<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>缓存全局变量</title>
</head>
<body>
    <input type="button" id="btn1">
    <input type="button" id="btn2">
    <input type="button" id="btn3">
    <input type="button" id="btn4">
    <input type="button" id="btn5">
    <input type="button" id="btn6">
    <input type="button" id="btn7">
    <input type="button" id="btn8">
    <input type="button" id="btn9">
    <input type="button" id="btn10">
</body>
<script>
    function fn1() {
        const btn1 = document.getElementById('btn1');
        const btn2 = document.getElementById('btn2');
        const btn3 = document.getElementById('btn3');
        const btn4 = document.getElementById('btn4');
        const btn5 = document.getElementById('btn5');
        const btn6 = document.getElementById('btn6');
        const btn7 = document.getElementById('btn7');
    }

    function fn2() {
        const obj = document;
        const btn1 = obj.getElementById('btn1');
        const btn2 = obj.getElementById('btn2');
        const btn3 = obj.getElementById('btn3');
        const btn4 = obj.getElementById('btn4');
        const btn5 = obj.getElementById('btn5');
        const btn6 = obj.getElementById('btn6');
        const btn7 = obj.getElementById('btn7');
    }


</script>

</html>